<% 
	/* Cookies语法包装 */
	var Cookies=
	{
		get:function()
		{
			if(arguments.length<1) throw new Error('');
			if(arguments.length>1)
			{
				return Request.Cookies(arguments[0])(arguments[1]);
			}
			else
				return Request.Cookies(arguments[0]);
		},
		set:function()
		{
			if(arguments.length<2||arguments.length>3) throw new Error('');
			if(arguments.length==3)
				Response.Cookies(arguments[0])(arguments[1])=arguments[2];
			else
				Response.Cookies(arguments[0])=arguments[1];
		},
		setAttribute:function($key,$attribute,$attributeValue)
		{
			Response.Cookies($key)[$attribute]=$attributeValue;
		},
		remove:function()
		{
			if(arguments.length<1) throw new Error('请提供要删除的Cookies的键名。');
			if(arguments.length==1)
				Response.Cookies(arguments[0])='';
			else
				Response.Cookies(arguments[0])(arguments[1])='';
		},
		tree:function($returnType)
		{
			var result='';
			if(Request.Cookies.Item!='')
			{
				this.keys().each
				(
					function($v,$i)
					{
						var tempObject=Request.Cookies($v);
						if(tempObject.HasKeys==true)
						{
							var tempArray0=tempObject.item.split('&');
							
							result+=($v+'==>{');
							for(var iCookies=0;iCookies<tempArray0.length;iCookies++){
								var tempArray1=tempArray0[iCookies].split('=');
								result+=(tempArray1[0]+':'+tempArray1[1]+',');							
							}
							result=result.substring(0,result.length-1);
							result+=('}<br/>');						
						}
						else
							result+=($v+'==>'+Request.Cookies($v)+'<br/>');				
					}
				);
			}
			return result;
		},
		each:function($iterator,$context)
		{
			$iterator=$iterator.bind($context);
			
			var tempObject=Request.Cookies;
			for(var iCookies=1;iCookies<=tempObject.Count;iCookies++)
			{
				$iterator(tempObject.Item(iCookies),iCookies);
			}
		},
		exists:function($key)
		{
			return this.keys().include($key);
		},
		abandon:function()
		{
			var tempArray=this.keys();
			tempArray.map
			(
				function($v,$i)
				{
					try
					{
						Response.Cookies($v)='';
					}
					catch(e)
					{}
				}
			);
		},
		keys:function()
		{
			var result=[];
			var tempArray=Request.Cookies.Item.split(';');
			tempArray.map
			(
				function($v,$i)
				{
					result.push($v.split('=')[0]);
				}
			);
			return result;
		},
		values:function()
		{
			var result=[];
			var tempArray=Request.Cookies.Item.split(';');
			tempArray.map
			(
				function($v,$i)
				{
					if(Request.Cookies($v.split('=')[0]).HasKeys==false)
						result.push($v.split('=')[1]);
					else
					{
						var tempValue=$v.substring($v.indexOf('=')+1,$v.length);
						result.push(tempValue);						
					}
				}
			);
			return result;			
		}
	};
%>